<template>
  <div class="base-custom-loading">
    <div class="base-custom-loading_inner">
      <i v-if="iconType === 'icon'" :class="loadingIcon"></i>
      <img v-else-if="iconType === 'image'" :src="loadingIcon" />
      <BaseSvg v-else :icon-class="loadingIcon" />
      <span>{{ loadingText }}</span>
    </div>
  </div>
</template>

<script>
import BaseSvg from "../SvgIcon/index.vue"
export default {
  name: "BaseLoading",
  components: { BaseSvg },
  props: {
    loadingText: {
      type: String,
      default: '加载中...'
    },
    loadingIcon: { // 默认是element图标
      type: String,
      default: 'el-icon-loading'
    },
    iconType: { // icon 图标 image 图片 svg svg图片
      type: String,
      default: 'icon'
    }
  },
  data() {
    return {}
  }
}
</script>

<style lang="scss" scoped>
.base-custom-loading {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.2);

  & > .base-custom-loading_inner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 148px;
    height: 148px;
    transform: translate(-50%, -50%);
    background: #ffffff;
    box-shadow: 0px 12px 48px 16px rgba(0, 0, 0, 0.03),
      0px 9px 28px 0px rgba(0, 0, 0, 0.05),
      0px 6px 16px -8px rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    display: flex;
    align-items: center;
    flex-direction: column;
    justify-content: center;
    flex-wrap: wrap;

    & > * {
      width: 46px;
      height: 46px;
      font-size: 46px;
      color: #1d7bf3;
    }

    & > span {
      width: 100%;
      height: 24px;
      font-size: 14px;
      font-family: "Microsoft YaHei";
      color: #666666;
      line-height: 24px;
      text-align: center;
      margin-top: 16px;
    }
  }
}
</style>
